import {Dialog, I18Parse, Util,JsConstant} from '@lowcode/jpaas-common-lib'
import FormDbApi from "@/api/form/bo/formDb";
import SelectSetting from "@/views/modules/form/bo/controlSetting/SelectSetting"
import {dragControls} from "./DragControls.js";
import apiFormBoLang from '../../../locales/lang/impl/form/apiFormBoLang';

let lang = apiFormBoLang;
let i18n=function (langKey,text) {
    return I18Parse.getI18Val(lang.apiFormBo,langKey, text)
}
export default {
    data() {
        return {
            controls:dragControls,
            dataTypes:[],
            defDbFieldType:{},
            dbFieldTypes:[],
            lengthInclud:['input','textarea','checkbox','radio','number','select','treeSelect','upload','user','group','hidden'],
            dataTypeInclud:['input','textarea','editor'],
            isSingleInclud:['radio','select','treeSelect'],
            controlJson:{},
            refJson:{'address':['province','city','city_code','county','county_code','address']},
            mappingFields:[{"value": "ID_","fieldName": "ID_","label": this.$ti18('rxForm.id', '主键'),"dataType": "varchar",},
                {"value": "REF_ID_","fieldName": "REF_ID_","label": this.$ti18('rxForm.refId', '外键'),"dataType": "varchar"},
                {"value": "INST_ID_","fieldName": "INST_ID_","label": i18n('instanceID','流程实例ID'),"dataType": "varchar"},
                {"value": "PARENT_ID_","fieldName": "PARENT_ID_","label": i18n('parentId','父ID'),"dataType": "varchar"},
                {"value": "INST_STATUS_","fieldName": "INST_STATUS_","label": i18n('instStatus','流程实例状态'),"dataType": "varchar"},
                {"value": "CREATE_BY_","fieldName": "CREATE_BY_","label": i18n('creator','创建人'),"dataType": "varchar"},
                {"value": "CREATE_TIME_","fieldName": "CREATE_TIME_","label": this.$ti18('rxForm.createTime','创建时间'),"dataType": "datetime"},
                {"value": "UPDATE_BY_","fieldName": "UPDATE_BY_","label": i18n('updateBy','更新人'),"dataType": "varchar"},
                {"value": "UPDATE_TIME_","fieldName": "UPDATE_TIME_","label": i18n('updateTime','更新时间'),"dataType": "datetime"},
                {"value": "TENANT_ID_","fieldName": "TENANT_ID_","label": i18n('tenantId','租户ID'),"dataType": "varchar"},
                {"value": "CREATE_DEP_ID_","fieldName": "CREATE_DEP_ID_","label": i18n('deptId','创建部门ID'),"dataType": "varchar"},
                {"value": "UPDATE_VERSION_","fieldName": "UPDATE_VERSION_","label": i18n('version','版本号'),"dataType": "number"},
                {"value": "USER_INFO_","fieldName": "USER_INFO_","label": i18n('userInfo','用户信息'),"dataType": "varchar"},
                {"value": "COMPANY_ID_","fieldName": "COMPANY_ID_","label": i18n('companyID','公司ID'),"dataType": "varchar"},
                {"value": "DELETED_","fieldName": "DELETED_","label": i18n('logicalDelete','逻辑删除'),"dataType": "int"}
            ],
            mappingField:"",
            dataSourceAlias:{},
            //默认的标准字段
            defField:[
                {name:'id',fieldName:'ID_','comment':this.$ti18('rxForm.id', '主键'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"ID_"}',isPk:1,isNotNull:1, isSingle:1,spans:1,type:"add"},
                {name:'tenantId',fieldName:'TENANT_ID_','comment':i18n('institutionID','机构ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"TENANT_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'createBy',fieldName:'CREATE_BY_','comment':i18n('createByID','创建人ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"CREATE_BY_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'updateBy',fieldName:'UPDATE_BY_','comment':i18n('updateByID','更新人ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"UPDATE_BY_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'createTime',fieldName:'CREATE_TIME_','comment':this.$ti18('rxForm.createTime','创建时间'),dataType:'default',dbFieldType:'datetime',
                    length:0,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"CREATE_TIME_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'updateTime',fieldName:'UPDATE_TIME_','comment':i18n('updateTime','更新时间'),dataType:'default',dbFieldType:'datetime',
                    length:0,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"UPDATE_TIME_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'createDepId',fieldName:'CREATE_DEP_ID_','comment':i18n('deptId','创建部门ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"CREATE_DEP_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'refId',fieldName:'REF_ID_','comment':this.$ti18('rxForm.refId', '外键'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"REF_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'parentId',fieldName:'PARENT_ID_','comment':i18n('parentId','父ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"PARENT_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'updateVersion',fieldName:'UPDATE_VERSION_','comment':i18n('version','版本号'),dataType:'default',dbFieldType:'decimal',
                    length:14,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"UPDATE_VERSION_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'userInfo',fieldName:'USER_INFO_','comment':i18n('userInfo','用户信息'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"USER_INFO_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'companyId',fieldName:'COMPANY_ID_','comment':i18n('companyID','公司ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"COMPANY_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'instId',fieldName:'INST_ID_','comment':i18n('instanceID','流程实例ID'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"INST_ID_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'instStatus',fieldName:'INST_STATUS_','comment':i18n('instStatus','流程实例状态'),dataType:'default',dbFieldType:'varchar',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"INST_STATUS_"}',isNotNull:0, isSingle:1,spans:1,type:"add"},
                {name:'deleted',fieldName:'DELETED_','comment':i18n('logicalDelete','逻辑删除'),dataType:'default',dbFieldType:'int',
                    length:64,decimalLength:0,control:'rx-commonfield',extJson:'{"mappingField":"DELETED_"}',isNotNull:0, isSingle:1,spans:1,type:"add"}
            ],
            //基础表
            isBasic:false,
        }
    },
    computed:{
        table(){
            return this.$refs.table;
        },
        dsAlias(){
            return this.$refs.dsAlias;
        }
    },
    methods:{
        onload_(values){
            var dsAlias="";
            if(values){
                this.fields=values.boAttrList;
                this.dataSourceAlias= {alias:values.dsAlias, name:values.dsName};
                dsAlias=values.dsAlias;
                if(this.$refs.dsAlias && (!this.dataSourceAlias.alias || this.pkId==null || !this.mdl.gendb)){
                    this.$refs.dsAlias.setVal(values.dsAlias,values.dsName);
                }
                //增加分页记录
                if(values.alias){
                    let key="BoEnt_" +values.alias;
                    let showPage=Util.getKey(key);
                    if(showPage!==null && showPage!=undefined){
                        this.showPage=showPage=="true";
                    }
                }
                //是否为基础表
                this.isBasic = values.isBasic == 1 ? true : false;
            }

            this.getDbFieldType(dsAlias);
        },
        saveAttr() {
            if (!this.controlJson.name) {
                this.$notification["warning"]({
                    message: i18n('attrPrompt','字段属性提示'),
                    description: i18n('enterName','请输入字段名'),
                });
                return;
            }
            if (!this.controlJson.control) {
                this.$notification["warning"]({
                    message: i18n('attrPrompt','字段属性提示'),
                    description: i18n('selectType','请输入控件类型'),
                });
                return;
            }
            if(this.controlJson.dataType=='number' && !this.controlJson.decimalLength){
                this.controlJson.decimalLength=0;
            }
            delete this.controlJson['label'];
            delete this.controlJson['value'];
            var json = Util.deepClone(this.controlJson);
            if(this.mdl.genMode=='db'){
                //地址控件
                if(json.control=="address"){
                    json.extJson.p_code=this.controlJson.name;
                    if(!json.extJson.province){
                        this.$notification["warning"]({
                            message: i18n('attrPrompt','字段属性提示'),
                            description: i18n('noSelect','未选择省名称!'),
                        });
                        return;
                    }
                }else if(json.control=="rx-commonfield"){
                    var extJson;
                    if(json.extJson && typeof(json.extJson)=="string" ){
                        extJson=JSON.parse(json.extJson);
                    }else {
                        extJson=json.extJson;
                    }
                    if(!extJson.mappingField){
                        this.$notification["warning"]({
                            message: i18n('attrPrompt','字段属性提示'),
                            description: i18n('noSelectMap','未选择映射字段!'),
                        });
                        return;
                    }
                }
            }
            if(!json.extJson){
                json.extJson="{}";
            }else {
                if(this.mdl.genMode=='db' && json.isSingle==0 && !json.extJson.ref && this.controlJson.control!="address"){
                    this.$notification["warning"]({
                        message: i18n('attrPrompt','字段属性提示'),
                        description: i18n('selectField','请选择关联字段'),
                    });
                    return;
                }
            }
            var isExist = false;
            var rows = this.table.getData();
            var refs=[];
            for (var i = 0; i < rows.length; i++) {
                if (rows[i]['idx_'] == json['idx_']) {
                    isExist = true;
                    this.table.updateRow(rows[i], json);
                }
                if(this.getRefAttr(rows[i],json)){
                    refs.push(rows[i]);
                }
            }
            if (!isExist) {
                this.table.addRow(json);
                this.controlJson['idx_'] = json['idx_'];
            }
            for(var i=0;i<refs.length;i++){
                this.table.updateRow(refs[i],{control:'rx-ref'});
            }
            this.aDrawerVisible = false;
        },
        delAttr(){
            const {fields,controlJson}=this;
            if(controlJson){
                for (var i = 0; i < fields.length; i++) {
                    if(controlJson.idx_==fields[i].idx_){
                        fields.splice(i, 1);
                    }
                }
            }
        },
        showDel(){
            if(this.controlJson.isDel){
                return true;
            }else {
                return false;
            }
        },
        getRefAttr(row,json){
            var extJson;
            if(typeof(json.extJson)=="string" ){
                extJson=JSON.parse(json.extJson);
            }else {
                extJson=json.extJson;
            }
            if(this.refJson.hasOwnProperty(json.control)){
                var ary=this.refJson[json.control];
                for(var i=0;i<ary.length;i++){
                    if(row.name==extJson[ary[i]]){
                        return true;
                    }
                }
            }else{
                if(row.fieldName==extJson.ref){
                    return true;
                }
            }
            return false;
        },
        getFromDb(){
            var dsName = this.dsAlias? this.dsAlias.getVal().value:"";
            Dialog.openTableQueryDialog({
                curVm:this,widthHeight:['900px','700px'],data:{ds:dsName}
            },function(self,data){
                self.loadByTable(data.tableName,dsName,"db");
            })
        },
        toHump(val) {
            let result='';
            if(val) {
                //默认取现在的别名
                var field= this.fields.find((item) => item.fieldName === val);
                if(field){
                    return field.name;
                }
                val = val.toLowerCase();
                const arr = val.split('_')
                arr.forEach((ele,index)=>{
                    for(let i=0;i<ele.length;i++){
                        let item=ele[i];
                        if(index>0 && i==0){
                            item=ele[i].toUpperCase();
                        }
                        result +=item;
                    }
                })
            }
            return result;
        },
        //表名、数据源、模式
        loadByTable(tbName,dsAlias,genMode) {
            var dsName =dsAlias
            if(!dsName){
                dsName = this.dsAlias?this.dsAlias.getVal().value:"";
            }
            FormDbApi.getByName("dsName="+dsName+"&tbName="+tbName).then(data=>{
                var list=this.conertData(data.columnList,genMode);
                this.fields=list;
                var json={
                    alias:this.mdl.alias || data.tableName,
                    dsAlias:dsName,
                    tableName:data.tableName,
                    name:data.comment,
                    genMode:genMode || 'db',
                    gendb:1,
                    idField:this.getPkField(list),
                    type:"upd"
                };
                this.$set(this,"mdl",json);
                this.form.setFieldsValue(this.mdl);
            })
        },
        conertData(list,genMode){
            var rtnList=[];
            for(var i=0;i<list.length;i++){
                var tmp=list[i];
                var _fieldName = tmp.fieldName.toUpperCase();
                var field= this.mappingFields.find((item) => item.fieldName === _fieldName);
                //只有从数据库生成才需要将标准字段取出
                if(field && genMode!="db"){
                    continue;
                }
                var oldField=this.fields.find((item) => item.fieldName === _fieldName);
                var o={};
                if(oldField){
                    o=oldField;
                }else {
                    o.name=tmp.name || this.toHump(tmp.fieldName);
                    o.fieldName=tmp.fieldName;
                    o.comment=tmp.comment;
                    o.isSingle=1;
                    o.dbFieldType=tmp.dbFieldType;
                    o.spans=tmp.spans || 1;
                }
                o.dataType=tmp.columnType;
                o.isPk=tmp.isPk;
                if(o.isPk==1){
                    o.isNotNull=1;
                }else {
                    o.isNotNull=tmp.isNotNull || 0;
                }
                o.decimalLength=tmp.decimalLen;
                //与标准字段同名则默认为标准字段
                if(field){
                    o.dataType = "default";
                    if(!oldField){
                        o.control = "rx-commonfield";
                        o.extJson=JSON.stringify({
                            "mappingField":_fieldName
                        });
                    }
                    o.length=tmp.columnType=="number"?tmp.intLen:tmp.charLen;
                }
                else if(tmp.columnType=="number"){
                    o.length=tmp.intLen;
                    if(!oldField){
                        o.control="number";
                    }
                }
                else if(tmp.columnType=="int"){
                    o.length=tmp.intLen;
                    if(!oldField){
                        o.control="number";
                    }
                }
                else if(tmp.columnType=="date"){
                    if(!oldField){
                        o.control="date";
                    }
                }
                else if(tmp.columnType=="clob"){
                    if(!oldField){
                        o.control="textarea";
                    }
                } else{
                    o.length=tmp.charLen;
                    if(!oldField){
                        o.control="input";
                    }
                }
                rtnList.push(o);
            }
            return rtnList;
        },
        getPkField(list){
            for(var i=0;i<list.length;i++){
                var o=list[i];
                if(o.isPk){
                    return o.fieldName;
                }
            }
            return "";
        },
        openDataSource(vm) {
            Dialog.openDataSourceDialog({
                curVm: this, widthHeight: ['800px', '600px'],
                data:{appName:JsConstant.JPAAS_LOWCODE}
            }, function (self, data) {
                vm.setVal(data.alias, data.name);
            })
        },
        onDel() {

            let self_ = this;
            var rows=self_.table.getSelectedRows();
            if(!rows || rows.length==0){
                this.$message.error(i18n('atLeastOne','请选择至少一行！'));
                return;
            }
            this.$confirm({
                title: this.$ti18('rxMsa.actionTips','操作提示'),
                content: this.$ti18('rxMsa.delInfo','您确定需要删除选中的记录吗？'),
                zIndex: 20000,
                okText: this.$ti18('rxForm.ackBtn','确认'),
                cancelText: this.$ti18('rxForm.cancelBtn','取消'),
                onOk() {
                    rows.forEach(row=>{
                        let index = self_.fields.findIndex(field=>{return field.idx_ === row.idx_});
                        self_.fields.splice(index,1);
                    })
                    self_.searchVal="";
                },
                onCancel() {
                }
            })
        },
        onCancel(){
            this.controlJson={};
        },
        addRow() {
            this.searchVal="";
            this.controlJson={};
            let id = Util.randomId();
            let max=this.getMaxSn()+10;

            var obj={
                idx_:id,
                comment:"",
                name:"",
                fieldName:"",
                control:"input",
                dataType:"varchar",
                dbFieldType:"varchar",
                isSingle:1,
                length:50,
                decimalLength:0,
                extJson:{},
                isDel:true,
                spans:1,
                isPk:0,
                isNotNull:0,
                type:"add",
                sn:max
            };
            this.fields.push(obj);
        },
        getMaxSn(){
            let max=0;
            this.fields.forEach(item=>{
                max=item.sn>max?item.sn:max;
            })
            return max;
        },

        upRow() {
            this.table.moveUp();
            this.reGenerateSn();
        },
        downRow() {
            this.table.moveDown();
            this.reGenerateSn();
        },
        reGenerateSn(){
          let fields=  this.table.getData();
          for(let i=0;i<fields.length;i++){
              let field=fields[i];
              field.sn=(i+1) *10;
          }
        },

        rowClick(record) {
            this.aDrawerVisible = true;
            //清空内容
            this.controlJson={};
            this.controlJson = Util.deepClone(record);
            if(this.controlJson.extJson && typeof(this.controlJson.extJson)=="string" ){
                this.controlJson.extJson=JSON.parse(this.controlJson.extJson);
            }
            this.mappingField="";
            //获取映射字段
            if(this.controlJson.dataType=='default' && this.controlJson.extJson){
                var extJson=this.controlJson.extJson;
                if(extJson && extJson.mappingField){
                    this.mappingField=extJson.mappingField;
                }
            }
            this.getDbFieldTypes(record);
        },
        getControl(name) {
            for(var i=0;i<this.controls.length;i++){
                if(name==this.controls[i].value){
                    return this.controls[i];
                }
            }
        },
        attrChange(value,name,record){

            if(name=='control') {
                var control = this.getControl(value);

                Object.assign(record, control);
                record.dataType= control.dataType[0];
                record.dbFieldType=this.defDbFieldType[record.dataType][0];
                this.dbFieldTypeChange(record.dbFieldType,record);
            }else{
                var json={};
                json[name]=value;
                Object.assign(record,json);
            }
        },
        showLength(){
            var ctl=this.controlJson.control;
            if(!ctl || this.lengthInclud.includes(ctl)){
                return true;
            }
            return false;
        },
        showIsSingle(){
            var ctl=this.controlJson.control;
            if(!ctl || this.isSingleInclud.includes(ctl)){
                return true;
            }
            return false;
        },
        showExtJson(){
            //只有db情况才显示
            if(!this.mdl.genMode || this.mdl.genMode=='form' || this.mdl.genMode=='create'){
                return false;
            }
            var isSingle=this.controlJson.isSingle;
            if(isSingle==0 ){
                return true;
            }
            return false;
        },
        showSetting(){
            //表单生成的不显示
            if(this.mdl.genMode=='form'){
                return false;
            }
            //先去掉下拉树
            if(!this.controlJson.control &&this.controlJson.control=="treeSelect" ){
                return false;
            }
            //地址控件直接显示
            if(this.controlJson.control && this.controlJson.control=="address" ){
                return true;
            }
            var  control = this.isSingleInclud.find((item) => {
                return item == this.controlJson.control;
            })
            if(!control){
                return false;
            }
            return true;
        },
        renderName(record){
            return record.name;
        },
        renderDataType(record){
            var val=record.dbFieldType;
            if(!record.decimalLength || record.decimalLength==0){
                if(val=="datetime" || val=="date" || val=="timestamp"){
                    return val;
                }else {
                    return val +"("+record.length+")";
                }
            }
            else{
                return val +"("+record.length +","+record.decimalLength+")"
            }
        },
        renderControlType(record){
            var val = record.control;
            if(val.length==0) return;
            var display=this.getControl(val).label;
            return display;
        },
        mappingChange(value){
            if(!this.controlJson.extJson) {
                this.controlJson.extJson = "{}";
            }
            var extJson;
            if(this.controlJson.extJson && typeof(this.controlJson.extJson)=="string" ){
                extJson=JSON.parse(this.controlJson.extJson);
            }else {
                extJson=this.controlJson.extJson;
            }
            extJson["mappingField"]=value;
            this.controlJson.extJson=JSON.stringify(extJson);
            if(value){
                for (let i = 0; i < this.defField.length; i++) {
                    if(this.defField[i].fieldName==value){
                        this.controlJson.length=this.defField[i].length;
                        this.controlJson.decimalLength=this.defField[i].decimalLength;
                        this.controlJson.isNotNull=this.defField[i].isNotNull;
                        this.controlJson.isSingle=this.defField[i].isSingle;
                        this.controlJson.isPk=this.defField[i].isPk;
                    }
                }
            }
        },
        //数据类型筛选
        filterOption(input, option) {
            return (
                option.componentOptions.children[0].text.toUpperCase().indexOf(input.toUpperCase()) >= 0
            );
        },
        //根据数据获取所有的数据类型
        getDbFieldType(dsAlias){
            FormDbApi.getDbFieldType(dsAlias).then(res=>{
                if(res.success){
                    this.defDbFieldType=res.data;
                }
            });
        },
        //根据控件获取数据类型
        getDbFieldTypes(record){
            if(record && record.control && this.defDbFieldType){
                var dbFieldTypes=[];
                var control=this.getControl(record.control);
                for (let i = 0; i < control.dataType.length; i++) {
                    var dataType=control.dataType[i];
                    if(this.defDbFieldType[dataType]){
                        dbFieldTypes.push(...this.defDbFieldType[dataType]);
                    }
                }
                this.dbFieldTypes=dbFieldTypes;
            }else {
                this.dbFieldTypes=[];
            }
        },
        //数据类型变化
        dbFieldTypeChange(value,record){
            if(value){
                var types=Object.values(this.defDbFieldType);
                var keys=Object.keys(this.defDbFieldType);
                for (let i = 0; i < types.length; i++) {
                    if(types[i].indexOf(value)!=-1){
                        if(keys[i]){
                            record.dataType=keys[i];
                            if(record.dataType!='number'){
                                record.decimalLength=0;
                            }
                            if(record.dataType=='clob' || record.dataType=='date'){
                                record.length=0;
                            }
                        }
                    }
                }
            }
        },
        setSetting(){
            var dataSource=null;
            var extJson={};
            if(this.controlJson && this.controlJson.extJson){
                if(typeof(this.controlJson.extJson)=='string'){
                    extJson=JSON.parse(this.controlJson.extJson);
                }
                else if(typeof(this.controlJson.extJson)=='object'){
                    extJson=this.controlJson.extJson;
                }
                if(extJson.dataSource){
                    dataSource=extJson.dataSource
                }
            }
            var self=this;
            Util.open({
                component: SelectSetting,
                curVm: this,
                zIndex:999999,
                widthHeight: ['1024px', '600px'],
                title: i18n('dataConfig','数据来源配置'),
                data: {
                    fields:this.fields,
                    dataSource:dataSource
                },
            },  function (action,data) {
                if(action!="ok") return;
                extJson.dataSource=data;
                self.controlJson.extJson=extJson;
            })
        },
        //市配置为false时，需修改县与详情地址的
        changeCity(e) {
            if (!e.target.checked) {
                this.controlJson.extJson.isCounty = false;
                this.controlJson.extJson.isAddress = false;
            }
        },
        //县配置为false时，需修改详情地址
        changeCounty(e) {
            if (!e.target.checked) {
                this.controlJson.extJson.isAddress = false;
            }
        },
        /**
         * 修改排序后，进行排序。
         */
        onSort(){
            this.fields=this.fields.sort((item1,item2)=>{
                  return item1.sn-item2.sn;
            });

        }
    }
}